﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;

namespace ModelLayer
{
    [DataContract]
    public class FlightInstance
    {
        [DataMember]
        public TimeSpan FlightTime { get; set; }
        [DataMember]
        public DateTime ArrivalTime { get; set; }
        [DataMember]
        public DateTime DepartureTime { get; set; }
        [DataMember]
        public Flight Flight { get; set; }
        [DataMember]
        public Plane Plane { get; set; }
        [DataMember]
        public int FlightInstanceId { get; set; }

       
        public FlightInstance()
        {
            
        }
        //Overrides equals to compare two Flight instances on their id and their date and time.
        public override bool Equals(object _obj)
        {
            bool equal = false;
            FlightInstance objFlightInstance = (FlightInstance) _obj;
            
            if(FlightInstanceId.Equals(objFlightInstance.FlightInstanceId))
            {
                equal = true;
            }
            
            return equal;
        }
        //Overrides the string representation of the object
        public override string ToString()
        {
            return string.Format("Route id: {0} \n Start airport: {1} \n End airport: {2}  \n Departure time: {3} \n Arrival time: {4} \n Flight time: {5}", Flight.RouteId, Flight.Departure.ToString(), Flight.Arrival.ToString(),
               DepartureTime.ToString("dd/MM/yyyy HH:mm"), ArrivalTime.ToString("dd/MM/yyyy HH:mm"),FlightTime.ToString());
        }
    }
}
